package cn.usian.service.impl;

import cn.usian.dao.EmpDao;
import cn.usian.pojo.Emp;
import cn.usian.service.EmpService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmpServiceImpl implements EmpService {
    @Autowired
    private EmpDao empDao;


   /* public Page<Emp> findPage(Integer pageIndex, String ename) {
        LambdaQueryWrapper<Emp>queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.like(ename!=null,Emp::getEname,ename);

        return empDao.selectPage(new Page<Emp>(pageIndex,2),queryWrapper);
    }*/

    @Override
    public void add(Emp emp) {
        empDao.insert(emp);
    }

    @Override
    public void delete(Integer eid) {
        empDao.deleteById(eid);
    }

    @Override
    public Emp findByEid(Integer eid) {
        return empDao.selectById(eid);
    }

    @Override
    public void update(Emp emp) {
        empDao.updateById(emp);
    }

    @Override
    public List<Emp> findAll() {
        return empDao.selectList(null);
    }
}
